package cn.ulyer.core.config;


import cn.hutool.core.exceptions.ExceptionUtil;
import cn.ulyer.common.enums.ErrorCode;
import cn.ulyer.common.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionAdvise {

	public ExceptionAdvise(){
		log.info("global exception handler configured");
	}


	@ExceptionHandler(Exception.class)
	public Result handler(Exception e){
		log.error("system  error :{}", ExceptionUtil.stacktraceToString(e));
		return Result.fail(e.getMessage());
	}

}



